package com.common.utils.http;


import android.content.Context;

import com.common.android.utils.httpRequest.AutoLoginHttpRequest;
import com.common.android.utils.httpRequest.IHttpRequest;
import com.starappallcommon.R;

/**
 * 明星APP的自动登录http请求类
 * 修改了返回的字符串资源ID
 * <br>Created 2014-8-11 下午1:45:03
 * @version  V1.2
 * @author   linsj		
 *
 * @see 	 
 * 
 * Copyright(c) 2009-2014, TQ Digital Entertainment, All Rights Reserved
 *
 */
public class StarAppAutoLoginHttpRequest extends AutoLoginHttpRequest {
    private static StarAppAutoLoginHttpRequest _instance;
    //FRI lsj AutoLoginHttpRequest 合并代码,合并同一个类中
    /**
     * 获取单例
     * 
     * <br>Created 2014-8-11 下午2:16:08
     * @param ctx   上下文
     * @param appid 应用ID
     * @param type  登录类型
     * @return      实例
     * @author       linsj
     */
    public static IHttpRequest getInstance(Context ctx, int appid, int type) {
        if (_instance == null) {
            _instance = new StarAppAutoLoginHttpRequest(ctx, appid, type);
        }
        return _instance;
    }

    protected StarAppAutoLoginHttpRequest(Context ctx, int appid, int type) {
        super(ctx, appid, type);
    }

    @Override
    public int doGet(String mStrURL, StringBuilder receive) {
        int iRet = super.doGet(mStrURL, receive);
        
        //重定向资源ID        
        if(R.string.nd_socket_timeout_error == iRet){
            iRet = R.string.star_app_socket_timeout_error;
        }else if(R.string.nd_socket_error == iRet){
            iRet = R.string.star_app_socket_error;
        }else if(R.string.nd_connect_timeout_error == iRet){
            iRet = R.string.star_app_connect_timeout_error;
        }else if(R.string.nd_unknown_host_error == iRet){
            iRet = R.string.star_app_unknown_host_error;
        }
        
        return iRet;
    }
}
